package leetcode;

/**
 * @Project : ProgrammingExercises
 * @Package : Leetcode
 * @File : Q2486.java
 * @Author : WangRuoyu
 * @Date 2023/2/24 9:27
 */
public class Q2486 {
    public int appendCharacters(String s, String t) {
        int p = 0;
        int q = 0;

        while ((p < s.length()) && (q < t.length())) {
            if (s.charAt(p) == t.charAt(q)) {
                p++;
                q++;
            } else {
                p++;
            }
        }

        return t.length() - q;
    }

    public static void main(String[] args) {
        Q2486 sl = new Q2486();
        String s = "coaching";
        String t = "coding";
        System.out.println(sl.appendCharacters(s, t));
    }
}